//
//  NSData+dataTohexStr.m
//  UDKLib
//
//  Created by idiot.lin on 15/3/11.
//  Copyright (c) 2015年 biao.rao. All rights reserved.
//

#import "NSData+dataTohexStr.h"

@implementation NSData (dataTohexStr)
-(NSString *)dataToByteTohexStr
{
    Byte *bytes = (Byte *)[self bytes];
    NSString *hexStr=@"";
    for(int i=0;i<[self length];i++)
    {
        NSString *newHexStr = [NSString stringWithFormat:@"%x",bytes[i]&0xff];///16进制数
        if([newHexStr length]==1)
            hexStr = [NSString stringWithFormat:@"%@0%@",hexStr,newHexStr];
        else
            hexStr = [NSString stringWithFormat:@"%@%@",hexStr,newHexStr];
    }
    return hexStr;
}
@end
